• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17  package com.replica.replicaisland;
18 
19 public class EventRecorder extends BaseObject {
20 	public final static int COUNTER_ROBOTS_DESTROYED = 0;
21 	public final static int COUNTER_PEARLS_COLLECTED = 1;
22 	public final static int COUNTER_PEARLS_TOTAL = 2;
23 
24 	private Vector2 mLastDeathPosition = new Vector2();
25 	private int mLastEnding = -1;
26 	private int mRobotsDestroyed = 0;
27 	private int mPearlsCollected = 0;
28 	private int mPearlsTotal = 0;
29 
30 	@Override
reset()31 	public void reset() {
32 		mRobotsDestroyed = 0;
33 		mPearlsCollected = 0;
34 		mPearlsTotal = 0;
35 	}
36 
setLastDeathPosition(Vector2 position)37 	synchronized void setLastDeathPosition(Vector2 position) {
38 		mLastDeathPosition.set(position);
39 	}
40 
getLastDeathPosition()41 	synchronized Vector2 getLastDeathPosition() {
42 		return mLastDeathPosition;
43 	}
44 
setLastEnding(int ending)45 	synchronized void setLastEnding(int ending) {
46 		mLastEnding = ending;
47 	}
48 
getLastEnding()49 	synchronized int getLastEnding() {
50 		return mLastEnding;
51 	}
52 
incrementEventCounter(int event)53 	synchronized void incrementEventCounter(int event) {
54 		if (event == COUNTER_ROBOTS_DESTROYED) {
55 			mRobotsDestroyed++;
56 		} else if (event == COUNTER_PEARLS_COLLECTED) {
57 			mPearlsCollected++;
58 		} else if (event == COUNTER_PEARLS_TOTAL) {
59 			mPearlsTotal++;
60 		}
61 	}
62 
getRobotsDestroyed()63 	synchronized int getRobotsDestroyed() {
64 		return mRobotsDestroyed;
65 	}
66 
getPearlsCollected()67 	synchronized int getPearlsCollected() {
68 		return mPearlsCollected;
69 	}
70 
getPearlsTotal()71 	synchronized int getPearlsTotal() {
72 		return mPearlsTotal;
73 	}
74 }
75