Ejemplo n.º 1
0
        public static void Update(Enemy self, MainPart part)
        {
            var playerTr = part.player.transform;

            self.targetPosition1 = playerTr.position + playerTr.up * 2f + self.firstForward * 10f;
            self.sm.Update(self);
        }
Ejemplo n.º 2
0
        public static void TracePlayer(MainPart self, Transform cameraTr, Player player, List <CharaBase> friendList)
        {
            var bounds = GetBounds(self, player, friendList);
            var pos    = cameraTr.position;
            var tpos   = bounds.center + player.transform.forward * 2f;
            var npos   = Vector3.Lerp(pos, tpos, self.appCore.assetData.config.cameraSpeed * Time.deltaTime);

            pos = npos;
            cameraTr.position = pos;
        }
Ejemplo n.º 3
0
        public static Bounds GetBounds(MainPart self, Player player, List <CharaBase> friendList)
        {
            var ppos = player.transform.position;
            var min  = ppos;
            var max  = ppos;

            foreach (var friend in friendList)
            {
                var fpos = friend.transform.position;
                min = Vector3.Min(min, fpos);
                max = Vector3.Max(max, fpos);
            }
            var bounds = new Bounds();

            bounds.SetMinMax(min, max);
            return(bounds);
        }
Ejemplo n.º 4
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.º 5
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);
        }
Ejemplo n.º 6
0
        public static void updateCollision(MainPart self)
        {
            using (var lc1 = findChara(self.charaList, _item => _item.type == CharaType.Player || _item.type == CharaType.Slave))
                using (var lc2 = findChara(self.charaList, _item => _item.type == CharaType.Friend)) {
                    var list1 = lc1.list;
                    var list2 = lc2.list;
                    for (var i1 = 0; i1 < list1.Count; i1++)
                    {
                        var c1 = list1[i1];
                        for (var i2 = 0; i2 < list2.Count; i2++)
                        {
                            var friend = list2[i2];
                            if (friend.type != CharaType.Friend)
                            {
                                continue;
                            }
                            var v = c1.transform.position - friend.transform.position;
                            if (!isHit(c1, friend, 0.5f))
                            {
                                continue;
                            }
                            addSlave(self, self.player.charaBase, friend);
                        }
                    }
                }

            using (var lc1 = findChara(self.charaList, _item => _item.type == CharaType.Player || _item.type == CharaType.Slave))
                using (var lc2 = findChara(self.charaList, _item => _item.type == CharaType.Enemy)) {
                    var list1 = lc1.list;
                    var list2 = lc2.list;
                    for (var i1 = 0; i1 < list1.Count; i1++)
                    {
                        var c1 = list1[i1];
                        for (var i2 = 0; i2 < list2.Count; i2++)
                        {
                            var friend = list2[i2];
                            var v      = c1.transform.position - friend.transform.position;
                            if (c1.hp <= 0)
                            {
                                continue;
                            }
                            if (!isHit(c1, friend, 0.5f))
                            {
                                continue;
                            }
                            c1.hp = 0;
                            if (c1.type == CharaType.Slave)
                            {
                                removeSlave(self, self.player.charaBase, c1);
                            }
                            GameObject.Destroy(c1.gameObject);
                        }
                    }
                }

            using (var lc1 = findChara(self.charaList, _item => _item.type == CharaType.Ring))
                using (var lc2 = findChara(self.charaList, _item => _item.type == CharaType.Enemy)) {
                    var list1 = lc1.list;
                    var list2 = lc2.list;
                    for (var i1 = 0; i1 < list1.Count; i1++)
                    {
                        var ring = list1[i1];
                        for (var i2 = 0; i2 < list2.Count; i2++)
                        {
                            var enemy = list2[i2];
                            var v     = ring.transform.position - enemy.transform.position;
                            if (enemy.hp <= 0)
                            {
                                continue;
                            }
                            if (!isHit(ring, enemy, 0.7f))
                            {
                                continue;
                            }
                            enemy.hp = 0;
                            GameObject.Destroy(enemy.gameObject);
                        }
                    }
                }
        }
Ejemplo n.º 7
0
        public static bool waveUpdate(MainPart self)
        {
            // spawn
            bool hasEnemy;

            using (var lc = findChara(self.charaList, _chara => _chara.type == CharaType.Enemy)) {
                hasEnemy = 0 < lc.list.Count;
            }
            var waveArr = self.appCore.assetData.waveArr;

            if (self.waveIndex < waveArr.Length)
            {
                var spawnArr = waveArr[self.waveIndex].spawnArr;
                if (self.spawnIndex < spawnArr.Length)
                {
                    var spawn = spawnArr[self.spawnIndex];
                    if (self.spawnTime < spawn.time)
                    {
                        self.spawnTime += Time.deltaTime;
                    }
                    else
                    {
                        var enemyPrefab = self.appCore.assetData.getAsset <GameObject>("enemy");
                        var enemyPos    = self.prison.transform.position + new Vector3(spawn.position.x, spawn.position.y, 0f) * 10f;
                        var enemyRot    = Quaternion.LookRotation(self.player.transform.position - enemyPos);
                        var enemy       = GameObject.Instantiate(enemyPrefab, enemyPos, enemyRot, self.transform).GetComponent <CharaBase>();
                        enemy.gameInstanceId = self.createGameInstanceId();
                        enemy.OnCollisionEnterAsObservable().
                        TakeUntilDestroy(enemy.gameObject).
                        Subscribe(_coll => {
                            if (enemy.hp <= 0)
                            {
                                return;
                            }
                            if (_coll.gameObject.layer != LayerMask.NameToLayer("player"))
                            {
                                return;
                            }
                            self.hasPlayerDamage = true;
                        });


                        var speed = spawn.speed * (self.waveLoopCount + 1);
                        enemy.enemy().moveSpeed  *= speed;
                        enemy.enemy().angleSpeed *= speed;
                        self.charaList.Add(enemy);
                        self.spawnIndex += 1;
                    }
                }
                else
                {
                    if (!hasEnemy)
                    {
                        self.waveIndex += 1;
                        self.spawnIndex = 0;
                        self.spawnTime  = 0f;
                    }
                }
            }
            else
            {
                if (!hasEnemy)
                {
                    self.waveIndex      = 0;
                    self.spawnIndex     = 0;
                    self.spawnTime      = 0f;
                    self.waveLoopCount += 1;
                    return(true);
                }
            }
            return(false);
        }