Ejemplo n.º 1
0
        public static void updateAnim(CharaBase self)
        {
            var next = self.animName;

            if (self.hasRun)
            {
                next = "run";
            }
            else if (self.hasWalk)
            {
                next = "walk";
            }
            else if (self.hasRot)
            {
                next = "walk";
            }
            else
            {
                next = "idle";
            }
            if (self.animName != next)
            {
                var animator = self.GetComponentInChildren <Animator>();
                if (animator != null)
                {
                    animator.PlayInFixedTime(next, 0, 0.25f);
                }
                self.animName = next;
            }
            self.hasRun  = false;
            self.hasWalk = false;
            self.hasRot  = false;
            self.time   += Time.deltaTime;
        }
Ejemplo n.º 2
0
        public static void changeToSlave(CharaBase self)
        {
            Debug.Assert(self.type == CharaType.Friend);
            self.type = CharaType.Slave;
            var friend = self.friend();

            GameObject.Destroy(friend);
            var slave = self.gameObject.AddComponent <Slave>();

            slave.charaBase = self;
        }
Ejemplo n.º 3
0
        public static void changeToFriend(CharaBase self)
        {
            Debug.Assert(self.type == CharaType.Slave);
            self.type = CharaType.Friend;
            var slave = self.slave();

            GameObject.Destroy(slave);
            var friend = self.gameObject.AddComponent <Friend>();

            friend.charaBase = self;
        }
Ejemplo n.º 4
0
        public static bool isHit(CharaBase c1, CharaBase c2, float length)
        {
            var v         = c1.transform.position - c2.transform.position;
            var sqrLength = length * length;

            if (sqrLength < v.sqrMagnitude)
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 5
0
        public static void addSlave(MainPart self, CharaBase playerC, CharaBase friend)
        {
            if (friend.type != CharaType.Slave)
            {
                CharaBase.changeToSlave(friend);
            }
            removeSlave(self, playerC, friend);
            var player = playerC.player();
            var listL  = player.nodeListL;
            var listR  = player.nodeListR;

            var nodeList = (listL.Count < listR.Count) ? listL : listR;

            nodeList.Add(new PlayerNode()
            {
                nodeId = friend.gameInstanceId,
            });
        }
Ejemplo n.º 6
0
        public static void removeSlave(MainPart self, CharaBase playerC, CharaBase friend)
        {
            if (friend.type != CharaType.Slave)
            {
                CharaBase.changeToSlave(friend);
            }
            var player = playerC.player();
            var listL  = player.nodeListL;
            var listR  = player.nodeListR;

            listL.RemoveAll(_node => _node.nodeId == friend.gameInstanceId);
            listR.RemoveAll(_node => _node.nodeId == friend.gameInstanceId);


            var tangle = 0f;

            UpdateRing(self.player.nodeListL, tangle, self.player.angleSpeed);
            UpdateRing(self.player.nodeListR, tangle, self.player.angleSpeed);
        }