コード例 #1
0
        public float ActionReverse(PlayableModel entity, PuzzleEntityModel behind_up_tile)
        {
            entity.GetComponent <Animator>().SetFloat("Speed", -1);
            entity.GetComponent <Animator>().Play("jump_down", -1, 1);
            for (int i = 0; i < entity.transform.childCount; ++i)
            {
                entity.transform.GetChild(i).GetComponent <Animator>().SetFloat("Speed", 1);
                entity.transform.GetChild(i).GetComponent <Animator>().CrossFade("jump_down", 0.1f, -1, 1);
            }

            return(2.0f);
        }
コード例 #2
0
        public float ActionReverse(PlayableModel entity, PuzzleEntityModel behind_tile)
        {
            entity.GetComponent <Animator>().SetFloat("Speed", -1);
            entity.GetComponent <Animator>().Play("walk", -1, 1);
            for (int i = 0; i < entity.transform.childCount; ++i)
            {
                entity.transform.GetChild(i).GetComponent <Animator>().SetFloat("Speed", -1);
                entity.transform.GetChild(i).GetComponent <Animator>().CrossFade("walk", 0.1f, -1, 1);
            }

            return(entity.transform.GetChild(0).GetComponent <Animator>().GetCurrentAnimatorClipInfo(0).Length);
        }
コード例 #3
0
        public float Action(PlayableModel entity, PuzzleEntityModel dummy)
        {
            entity.GetComponent <Animator>().SetFloat("Speed", 1);
            entity.GetComponent <Animator>().Play("turn_right", -1, 0);

            for (int i = 0; i < entity.transform.childCount; ++i)
            {
                entity.transform.GetChild(i).GetComponent <Animator>().SetFloat("Speed", 1);
                entity.transform.GetChild(i).GetComponent <Animator>().CrossFade("turn_right", 0.3f, -1, 0);
            }

            return(entity.transform.GetChild(0).GetComponent <Animator>().GetCurrentAnimatorClipInfo(0).Length);
        }
コード例 #4
0
        public float Action(PlayableModel entity, PuzzleEntityModel front_down_tile)
        {
            if (!front_down_tile)
            {
                return(0.0f);
            }

            var cleanable = front_down_tile.GetComponent <CleanableModel>();

            if (cleanable && !cleanable.IsClean)
            {
                return(0.0f);
            }

            entity.GetComponent <Animator>().SetFloat("Speed", 1);
            entity.GetComponent <Animator>().Play("jump_down", -1, 0);
            for (int i = 0; i < entity.transform.childCount; ++i)
            {
                entity.transform.GetChild(i).GetComponent <Animator>().SetFloat("Speed", 1);
                entity.transform.GetChild(i).GetComponent <Animator>().CrossFade("jump_down", 0.1f, -1, 0);
            }

            return(2.0f);
        }
コード例 #5
0
        public float Action(PlayableModel attacker, PuzzleEntityModel front_tile)
        {
            if (!front_tile)
            {
                return(0.0f);
            }

            var target = front_tile.GetComponent <TileModel>().PuzzleEntity;

            var actionable = attacker.GetComponent <ActionableModel>();
            var damageable = target.GetComponent <DamageableModel>();

            if (!actionable || !damageable)
            {
                return(0.0f);
            }

            front_tile.GetComponent <TileModel>().PuzzleEntity = null;

            for (int i = 0; i < attacker.transform.childCount; ++i)
            {
                attacker.transform.GetChild(i).GetComponent <Animator>().CrossFade("attack", 0.1f, -1, 0);
            }

            damageable.HP -= actionable.Power;

            if (damageable.HP <= 0)
            {
            }

            float time = actionable.transform.GetChild(0).GetComponent <Animator>().GetCurrentAnimatorClipInfo(0).Length;

            CoroutineUtility.Instance.DelayAction(time * 0.8f, () => {
                damageable.GetComponent <Animator>().CrossFade("damaged", 0.1f, -1, 0);
                CoroutineUtility.Instance.DelayAction(3f, () => {
                    damageable.gameObject.SetActive(false);
                });
            });

            return(actionable.transform.GetChild(0).GetComponent <Animator>().GetCurrentAnimatorClipInfo(0).Length);
        }
コード例 #6
0
        private CommandModel getCommandFromLogFile(PlayableModel playable, string file_name_to_parse, string file_name_to_save)
        {
            var stream = new FileStream(Application.dataPath + "/Resources/" + file_name_to_parse, FileMode.OpenOrCreate, FileAccess.Read);
            var reader = new StreamReader(stream, System.Text.Encoding.Unicode);
            var json   = JSON.Parse(reader.ReadToEnd());

            reader.Close();
            stream.Close();

            if (json == null)
            {
                return(null);
            }

            var command_ids = json["commands"].AsArray;
            var result      = from command in GameObject.FindObjectsOfType <SingleCommandModel>()
                              where command.Playable.GetComponent <PuzzleEntityModel>().ID == playable.GetComponent <PuzzleEntityModel>().ID
                              select command;

            var single_commands = result.ToDictionary(x => x.GetComponent <SingleCommandModel>().ID);
            int count           = command_ids.Count - 1;

            while (count > -1 && !single_commands.ContainsKey(command_ids[count].AsInt))
            {
                count--;
            }

            if (count == -1)
            {
                return(null);
            }

            var return_value = single_commands[command_ids[count].AsInt];

            command_ids.Remove(command_ids[count]);

            PuzzlePlayLogSystem.Instance.FileName = file_name_to_parse;
            PuzzlePlayLogSystem.Instance.Log(json.ToString(4));

            PuzzlePlayLogSystem.Instance.FileName = file_name_to_save;
            PuzzlePlayLogSystem.Instance.Log(return_value);

            return(return_value);
        }