示例#1
0
    // Use this for initialization
    void Start()
    {
        createProjectile = gameObject.GetComponent <CreateProjectile>();

        //Initialiser des variables
        hp        = maxHp;
        fireTimer = 0;
    }
示例#2
0
        internal static Projectile GetAvailableProjectile(
            List <Projectile> gameObjects,
            CreateProjectile createProjectile,
            Unit.OnHit onHit,
            IAm iAm,
            ref int?projectileIndex
            )
        {
            Projectile go = null;
            int        i  = 0;

            foreach (Projectile obj in gameObjects)
            {
                if (obj.Available == true)
                {
                    go = obj;
                    projectileIndex = i;
                    //Debug.Log(obj.gameObject.activeSelf + " :" + DateTime.Now);
                    break;
                }
                i++;
            }

            if (go == null)
            {
                HitArea arrowHitArea = null;
                go = createProjectile(go);
                foreach (Transform hA in go.transform)
                {
                    arrowHitArea = hA.GetComponent <HitArea>();
                    if (arrowHitArea != null)
                    {
                        break;
                    }
                }
                if (arrowHitArea != null)
                {
                    arrowHitArea.Init(onHit, iAm.ToString(), isProjectile: true, projectile: go);
                }

                return(go);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
    // Use this for initialization
    void Start()
    {
        //Find the CreateProjectile.cs script
        shoot = GetComponent <CreateProjectile>();
        if (shoot == null)
        {
            Debug.LogError(this + " requires a CreateProjectile.cs script to function!");
        }

        //Find the EnemyAIValue.cs script
        valueScript = GetComponent <EnemyAIValue>();
        if (valueScript == null)
        {
            Debug.LogError(this + " doesn't have a EnemyAIValue.cs script!");
        }

        //Trouver la tourelle du tank
        Transform[] transforms = GetComponentsInChildren <Transform>();
        foreach (Transform transform in transforms)
        {
            if (transform.gameObject.name == "body" || transform.gameObject.name == "Body")
            {
                turret = transform.gameObject;
            }
        }
        if (turret == null)
        {
            Debug.Log("Le tank ne possède pas de tourelle!");
        }

        //Vérifier que le script possède un prefab de projectile
        if (projectile == null)
        {
            Debug.LogError(this + " requires a GameObject projectile to shoot!");
        }

        //Initialiser le timer
        fireTimer = 0;
    }