コード例 #1
0
ファイル: Tower.cs プロジェクト: WishnusArmy/Game
    public override void Update(object gameTime)
    {
        if (select)
        {
            GameWorld.FindByType <Overlay>()[0].TowerInfo.tower = this;
            select = false;
        }

        lagReducer = 1 + (towerAmount / 20);
        base.Update(gameTime);
        if (timer % lagReducer == 0)
        {
            gotEnemies = false;
        }

        if (timer <= 0)
        {
            if (target != null)
            {
                Attack();
            }
            timer = TowerRate(type, stats);
        }
        else if (timer > 0)
        {
            timer--;
        }


        if (myNode == null)
        {
            myNode       = MyPlane.NodeAt(GlobalPosition);
            myNode.solid = true;
            myNode.setDval(myNode, TowerRange(type, stats), new List <GridNode>(), (int)TowerDamage(type, stats) * 15);
            foreach (GridNode node in myNode.ExtendedNeighbours)
            {
                node.available = false;
            }
        }
        hover = myNode.selected; //check if the  mouse is hovering the tower

        //if target is out of range
        if (target != null && CalculateDistance(target.GlobalPositionCenter, GlobalPosition) > TowerRange(type, stats))
        {
            target = null;
        }

        if (target == null || target.Kill)
        {
            target = findTarget();
        }
    }
コード例 #2
0
ファイル: Base.cs プロジェクト: WishnusArmy/Game
    public override void Update(object gameTime)
    {
        if (canShoot)
        {
            baseTexture = SPR_BASE;
        }
        else
        {
            baseTexture = SPR_BASENOSHOOT;
        }

        base.Update(gameTime);
        timer--;

        if (myNodes == null)
        {
            myNodes = new List <GridNode>();
            myNodes.Add(MyPlane.NodeAt(position, true));
            myNodes.AddRange(myNodes[0].ExtendedNeighbours);
        }
        hover = false;
        foreach (GridNode node in myNodes)
        {
            if (node.selected)
            {
                hover = true;
            }
        }

        if (BaseHealth != previoushealth && !inAnimation)
        {
            inAnimation    = true;
            animationTimer = 0;
        }
        previoushealth = BaseHealth;
    }