Пример #1
0
		// Forces the animation of an anchored entity, so that it can't be messed with it's current animation events
		public static void SetAnchoredEntityAnimation(GameEntityModel model, int anchorId, string animationName){
			if (model.anchoredEntities == null || model.anchoredEntities.Count <= anchorId) return;
			GameEntityModel anchoredEntityModel = StateManager.state.GetModel(model.anchoredEntities[anchorId]) as GameEntityModel;
			if (anchoredEntityModel != null){
				AnimationModel anchoredAnimationModel = GameEntityController.GetAnimationModel(anchoredEntityModel);
				AnimationController anchoredAnimController = anchoredAnimationModel.Controller() as AnimationController;
				if (anchoredAnimController != null){
					// Force animation, so that it ignores any desired transition from a previous animation update 
					anchoredAnimController.ForceAnimation(anchoredAnimationModel, animationName);
				}
			}
		}
        // Check collision against other entity
        public bool CollisionCollisionCheck(GameEntityModel model, GameEntityModel otherModel)
        {
            AnimationModel      animModel      = GetAnimationModel(model);
            AnimationModel      otherAnimModel = GetAnimationModel(otherModel);
            AnimationController animController = animModel.Controller() as AnimationController;
            FixedVector3        position       = GetRealPosition(model);
            FixedVector3        otherPosition  = GetRealPosition(otherModel);

            if (animController.CollisionCollisionCheck(animModel, position, model.IsFacingRight(), otherAnimModel, otherPosition, otherModel.IsFacingRight()))
            {
                // Both entities get knowing they hit each other
                GameEntityController otherController = otherModel.Controller() as GameEntityController;
                otherController.lastCollisionEntityId = model.Index;
                lastCollisionEntityId = otherModel.Index;
//				Debug.Log("Collision detected");
                return(true);
            }
            return(false);
        }
        // Check Hit against other entity
        public void HitCollisionCheck(GameEntityModel model, GameEntityModel otherModel)
        {
            AnimationModel      animModel      = GetAnimationModel(model);
            AnimationModel      otherAnimModel = GetAnimationModel(otherModel);
            AnimationController animController = animModel.Controller() as AnimationController;
            FixedVector3        position       = GetRealPosition(model);
            FixedVector3        otherPosition  = GetRealPosition(otherModel);
            HitInformation      hitInformation = animController.HitCollisionCheck(
                animModel, position, model.IsFacingRight(),
                otherAnimModel, otherPosition, otherModel.IsFacingRight()
                );

            if (hitInformation != null)
            {
                // Both entities get knowing one hit the other
                GameEntityController otherController = otherModel.Controller() as GameEntityController;
                otherController.lastHurts.Add(hitInformation.HitWithEntity(model.Index));
                lastHits.Add(hitInformation.HitWithEntity(otherModel.Index));
                // Debug.Log(model.Index + " hit " + otherModel.Index);
            }
        }